<template>
  <el-card class="content">
    <div class="beachTable">
      <el-table
        style="width: 100%"
        border
        :data="list"
        text-align="center"
        :header-cell-style="{ 'text-align': 'center' }"
        :cell-style="{ 'text-align': 'center' }"
        size="small"
      >
        <el-table-column prop="monitorCode" label="测点编号"> </el-table-column>
        <el-table-column prop="monitorName" label="测点名称"></el-table-column>
        <el-table-column
          prop="beachTopElevation"
          label="滩顶高程(m)"
        ></el-table-column>
        <el-table-column prop="data" label="干滩长度(m)"></el-table-column>
        <el-table-column
          prop="dryBeachRatio"
          label="干滩坡比"
        ></el-table-column>
        <el-table-column prop="limitValue" label="限值(m)"></el-table-column>
        <el-table-column prop="theDate" label="数据时间"></el-table-column>
      </el-table>
    </div>
    <!-- <div id="beachCharts" class="beach"></div> -->
  </el-card>
</template>

<script>
import axios from "axios";
import { getLatestBeachData } from "../../../api/Monitoring";
import moment from "moment";
export default {
  name: "MinDryBeachLength",
  components: {},
  props: {
    node: Object,
  },
  data() {
    return {
      list: [],
      realDataInterVal: null,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    async getList() {
      const res = await getLatestBeachData({
        monitorCode: this.node.monitorCode,
        count: 17,
      });
      console.log(res)
      if (res.resultCode == "200") {
        this.list = res.parameter;
        console.log(this.list);
        for(let i = 0; i<res.parameter.length; i++){
          if(res.parameter[i].limitValue == null){
            res.parameter[i].limitValue = "/"
          }
          this.list.limitValue = res.parameter.limitValue;
        }
        console.log(this.list)
        this.list.forEach((item) => {
          item.data = item.data.toFixed(3);
          item.dryBeachRatio = Number(item.dryBeachRatio).toFixed(3);
        });
        

        // this.list.unshift({
        //   data:list.data,
        //   monitorCode:list.monitorCode,
        //   monitorName:list.monitorName,
        //   theDate:list.theDate
        // })
        //   this.newObj.length > 17 ? this.newObj.splice(17, 1) : null
      } else if (res.resultCode == "204") {
        this.list = [];
        this.$message.info("暂无数据");
      }
    },
  },
  computed: {},
  watch: {},
};
</script>

<style scoped>
.beach {
  /* width: 1200px; */
  height: 54vh;
  margin-top: 20px;
}
.content {
  width: 100%;
  height: 88vh;
  overflow: auto;
}
.beachTable {
  height: 82vh;
  overflow: auto;
}
.beachTable >>> .el-table tr:nth-child(odd) {
  /* background: pink; */
  text-align: center !important;
  color: #000;
  font-size: 12px;
}
.beachTable >>> .el-table tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.05);
  text-align: center !important;
  color: #000;
  font-size: 12px;
}
</style>